{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "3c92dd65",
   "metadata": {},
   "source": [
    "# 1. web最小应用"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "af0919bc",
   "metadata": {},
   "outputs": [],
   "source": [
    "from flask import Flask\n",
    "from flask import render_template,request\n",
    "app = Flask(__name__)\n",
    "\n",
    "\n",
    "@app.route('/')\n",
    "def index():\n",
    "    return render_template('index.html')\n",
    "\n",
    "@app.route('/introduction')\n",
    "def introduction():\n",
    "    return render_template('introduction.html')\n",
    "\n",
    "@app.route('/contact')\n",
    "def contact():\n",
    "    return render_template('contact.html')\n",
    "\n",
    "# 颜色选择应用的url地址，app.html是该地址的HTML页面文件\n",
    "@app.route('/colorapp')\n",
    "def colorapp():\n",
    "    return render_template('app.html')\n",
    "\n",
    "@app.route('/results',methods=[\"POST\"])\n",
    "def results():\n",
    "    # 等待处理用户提交的结果，接收用户提交的结果\n",
    "    print(request.form['selectcolor_up'])\n",
    "    print(request.form['selectcolor_down'])\n",
    "    return render_template('app.html',\n",
    "                          user_choose_color_up = request.form['selectcolor_up'],\n",
    "                          user_choose_color_down = request.form['selectcolor_down']\n",
    "                          )\n",
    "\n",
    "app.run()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "40e53480",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.11.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
